package com.qianli.cashmama.trade.client.trade.request;

import com.fqgj.common.api.ParamsObject;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.exception.common.ApplicationException;

import java.math.BigDecimal;

/**
 * @program: market-loan-trade
 * @description
 * @author: frank
 * @create: 2020-12-29 10:11
 **/
public class CreateServiceFeeRequest extends ParamsObject {


    /**
     *用户code
     */
    private String userCode;
    /**
     *支付金额
     */
    private BigDecimal payAmount;
    /**
     *渠道code
     */
    private String channelCode;
    /**
     *app版本
     */
    private String appVersion;
    /**
     *appCode
     */
    private String appCode;
    /**
     *包名
     */
    private String packageName;

    public String getUserCode() {
        return userCode;
    }

    public CreateServiceFeeRequest setUserCode(String userCode) {
        this.userCode = userCode;
        return this;
    }

    public BigDecimal getPayAmount() {
        return payAmount;
    }

    public CreateServiceFeeRequest setPayAmount(BigDecimal payAmount) {
        this.payAmount = payAmount;
        return this;
    }

    public String getChannelCode() {
        return channelCode;
    }

    public CreateServiceFeeRequest setChannelCode(String channelCode) {
        this.channelCode = channelCode;
        return this;
    }

    public String getAppVersion() {
        return appVersion;
    }

    public CreateServiceFeeRequest setAppVersion(String appVersion) {
        this.appVersion = appVersion;
        return this;
    }

    public String getAppCode() {
        return appCode;
    }

    public CreateServiceFeeRequest setAppCode(String appCode) {
        this.appCode = appCode;
        return this;
    }

    public String getPackageName() {
        return packageName;
    }

    public CreateServiceFeeRequest setPackageName(String packageName) {
        this.packageName = packageName;
        return this;
    }

    @Override
    public void validate() {
        if(StringUtils.isEmpty(userCode)){
            throw new ApplicationException("userCode can not be empty");
        }
        if(payAmount == null || payAmount.compareTo(BigDecimal.ZERO) == 0){
            throw new ApplicationException("payAmount is invalid");
        }
        if(StringUtils.isEmpty(channelCode)){
            throw new ApplicationException("channelCode can not be empty");
        }
        if(StringUtils.isEmpty(appVersion)){
            throw new ApplicationException("appVersion can not be empty");
        }
        if(StringUtils.isEmpty(appCode)){
            throw new ApplicationException("appCode can not be empty");
        }
        if(StringUtils.isEmpty(packageName)){
            throw new ApplicationException("packageName can not be empty");
        }
    }
}
